Skip to content

Implementation of sync_nonpoison and nonpoison_mutex #134663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Aandreba
Copy link

Implementation of sync_nonpoison and nonpoison_mutex
Docs come straight from the poisoned Mutex, so they need to be updated.

Tracked by:

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 22, 2024
@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

@Amanieu you may want to double check this

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 24, 2024
@rustbot

This comment was marked as resolved.

@Noratrieb
Copy link
Member

Looks like you messed up a rebase. No worries, mistakes like this happen sadly (thanks Git for being so hard to use!). To get rid of all these commits, do a git rebase -i upstream/master (where upstream is the rust-lang/rust remote) as described in https://rustc-dev-guide.rust-lang.org/git.html#i-made-a-merge-commit-by-accident.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Amanieu
Copy link
Member

Amanieu commented Dec 24, 2024

This seems fine as a first step. Longer term we may want to consider changing the poisoning mutexes to be a wrapper around a non-poisoning Mutex<Poison<T>>, but that can happen in a later PR.

@jieyouxu jieyouxu removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-meta Area: Issues & PRs about the rust-lang/rust repository itself PG-exploit-mitigations Project group: Exploit mitigations A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 24, 2024
@Aandreba
Copy link
Author

Mind rebasing at least? If the tests are still not blessing for you, I'll see if I can push a commit that updates them.

Done! Have a try, let me know If you need anything!

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

So, UI tests have two things that get checked:

  • Error annotations
  • Stderr

Error annotations just highlight the important changes / messages you want to see and need to get updated manually. The stderr files show what the full error output looks like, and get updated with --bless. I added a commit that did both, in most cases it just meant adding std::sync to the error annotations.

Take a read through https://rustc-dev-guide.rust-lang.org/tests/ui.html, it explains this in better detail.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing TIDY_PRINT_DIFF=1 npm install eslint@$(head -n 1 /tmp/eslint.version) &&  python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
+ head -n 1 /tmp/eslint.version
+ TIDY_PRINT_DIFF=1 npm install [email protected]
npm ERR! code E504
npm ERR! 504 Gateway Timeout - GET https://registry.npmjs.org/@humanwhocodes%2fconfig-array

npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-06-12T18_33_10_490Z-debug-0.log
  local time: Thu Jun 12 18:35:07 UTC 2025
  network time: Thu, 12 Jun 2025 18:35:07 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more small comments. Note that there are still some small unresolved comments above that need to be addressed.

Ignore the tidy check failure, looks like NPM might be partially down.

@@ -0,0 +1,10 @@
//! Non-poisoning syncronous locks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/syncronous/synchronous/

/// A mutual exclusion primitive useful for protecting shared data.
///
/// For more information about mutexes, check out the documentation for the
/// poisoning variant of this lock found at [std::sync::poison::Mutex](crate::sync::poison::Mutex).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: make this [`poison::Mutex`], and then add [`poison::Mutex`]: crate::sync::poison::Mutex to the bottom of the docs section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to check the panic behavior?

Comment on lines +359 to +360
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
pub fn map<U, F>(orig: Self, f: F) -> MappedMutexGuard<'a, U>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment // #[unstable(feature = "mapped_lock_guards", issue = "117108")] so we remember this is also unstable under that gate. It would be good to add the same to any API that uses MappedMutexGuard, and the MappedMutexGuard itself.

@tgross35
Copy link
Contributor

tgross35 commented Jul 7, 2025

@Aandreba gentle ping, are you able to get this over the line? The only things left are stable->unstable gate changes and documentation fixes, see the non-resolved review comments starting at #134663 (comment).

Let us know if you need any help.

@Aandreba
Copy link
Author

Aandreba commented Jul 7, 2025

@Aandreba gentle ping, are you able to get this over the line? The only things left are stable->unstable gate changes and documentation fixes, see the non-resolved review comments starting at #134663 (comment).

Let us know if you need any help.

I'm currently having problems rebasing master, so I'm stuck. Tomorrow I'll look into it more.

@tgross35
Copy link
Contributor

tgross35 commented Jul 7, 2025

If you're getting conflicts, you should try squashing before actually doing the rebase. Something like:

# set FETCH_HEAD to current latest master
git fetch https://github.com/rust-lang/rust.git master

# Squash without changing the base with --keep-base
# In the editor, change the "pick" in every line except the first to "fixup" or "f"
# This should complete without errors
git rebase -i FETCH_HEAD --keep-base

# Now do the actual rebase onto the latest master
git rebase -i FETCH_HEAD

That way you don't have to resolve conflicts for intermediate commits that aren't relevant anymore.

@Aandreba
Copy link
Author

@tgross35 The last step still gives me an error

@tgross35
Copy link
Contributor

Please be more specific if you need help. I tested it locally and it succeeded without conflicts.

@connortsui20
Copy link
Contributor

Hi @Aandreba, if your bandwidth is low, I would love to have a go at getting this to the finish line! I have some free time on my hands for the next few weeks.

@Aandreba
Copy link
Author

Hi @Aandreba, if your bandwidth is low, I would love to have a go at getting this to the finish line! I have some free time on my hands for the next few weeks.

Yeah, I don't really have much time for this right now, so that would be helpful :)

connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 16, 2025
connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 17, 2025
connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 18, 2025
connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 20, 2025
connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 21, 2025
@connortsui20
Copy link
Contributor

Whoops, sorry for the pings, I forgot I had the PR link in that first commit 🫤. Though in other news I think we will be able to get that PR through soon 🤞

connortsui20 pushed a commit to connortsui20/rust that referenced this pull request Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.